#include <iostream>
#include <stdio.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <arpa/inet.h>
#include <string.h>

#define BUF_SIZE 512
using namespace std;

int main(){
    int sd=socket(AF_INET,SOCK_DGRAM,0);
    if(0>sd){
        cout<<"create socket error"<<endl;
        return -1;
    }

    struct sockaddr_in addr;
    addr.sin_port=htons(5683);
    addr.sin_addr.s_addr=inet_addr("139.199.209.80");
    addr.sin_family=AF_INET;
    socklen_t addr_len= sizeof(addr);

    char send_buf[BUF_SIZE],recv_buf[BUF_SIZE];
//    socklen_t cli_len=sizeof(cli);
    int send_len=0;
    for(;;) {
        cin >> send_buf;
        if (0 > sendto(sd, send_buf, strlen(send_buf), 0, (struct sockaddr *) &addr, addr_len))
            break;
        memset(send_buf, 0, BUF_SIZE);


    }
    close(sd);
    cout<<"disconnect"<<endl;

}


